<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>自适应高度表格示例</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 0;
            padding: 20px;
            display: flex;
            justify-content: center;
            min-height: 100vh;
        }
        
        .main-container {
            width: 60%;
            display: flex;
            flex-direction: column;
        }
        
        .title {
            background-color: #e9ecef;
            padding: 15px;
            border-radius: 5px 5px 0 0;
            border: 1px solid #dee2e6;
            border-bottom: none;
            font-weight: bold;
            text-align: center;
            box-sizing: border-box;
        }
        
        .table-scroll-container {
            flex: 1; /* 占据剩余可用空间 */
            min-height: 200px; /* 最小高度保证 */
            max-height: 70vh; /* 最大高度限制 */
            overflow: auto; /* 滚动条 */
            border: 1px solid #dee2e6;
            background-color: #f8f9fa;
            box-sizing: border-box;
        }
        
        .table-container {
            padding: 20px;
        }
        
        table {
            width: 100%;
            border-collapse: collapse;
        }
        
        th, td {
            border: 1px solid #ddd;
            padding: 12px;
            text-align: left;
            min-width: 100px;
        }
        
        th {
            background-color: #e9ecef;
            position: sticky;
            top: 0;
        }
        
        tr:nth-child(even) {
            background-color: #f2f2f2;
        }
        
        tr:hover {
            background-color: #e9e9e9;
        }
        
        tr.selected {
            background-color: #cce5ff !important;
            font-weight: bold;
        }
        
        .button-container {
            padding: 15px;
            background-color: #f8f9fa;
            border: 1px solid #dee2e6;
            border-radius: 0 0 5px 5px;
            text-align: center;
            box-sizing: border-box;
        }
        
        button {
            padding: 10px 20px;
            margin: 0 10px;
            background-color: #007bff;
            color: white;
            border: none;
            border-radius: 4px;
            cursor: pointer;
        }
        
        button:hover {
            background-color: #0056b3;
        }
    </style>
</head>
<body>
    <div class="main-container">
        <div class="title">员工信息表 (点击行可选中)</div>
        
        <div class="table-scroll-container">
            <div class="table-container">
                <table id="dataTable">
                    <thead id="tableHead">
                       
                    </thead>
                    <tbody id="tableBody">
                        
                    </tbody>
                </table>
            </div>
        </div>
        
        <div class="button-container">
            <button>新增</button>
            <button>编辑</button>
            <button>删除</button>
            <button>保存</button>
        </div>
    </div>

    <script>
        
    </script>
</body>
</html>